home *** CD-ROM | disk | FTP | other *** search
/ Professor Iris Fun Field Trip: Seaside Adventure / Professor Iris - Fun Field Trip: Seaside Adventure.iso / pc / discovry / intro2.dir / 00002_TypingStuff.ls < prev    next >
Encoding:
Text File  |  1995-05-03  |  4.7 KB  |  169 lines

  1. on pInitTyping
  2.   global goTyping
  3.   if objectp(goTyping) then
  4.     goTyping(mdispose)
  5.   end if
  6.   set goTyping to fTyping(mnew)
  7.   when keyDown then goTyping(mHitKey)   
  8. end
  9.  
  10. on pStopTyping
  11.   global goTyping
  12.   repeat with x = 4 to 14
  13.     if the puppet of sprite x = 1 then
  14.       set the visible of sprite x to 0
  15.       puppetSprite(x, 0)
  16.       set the visible of sprite x to 1
  17.     end if
  18.   end repeat
  19.   if objectp(goTyping) then
  20.     goTyping(mSetPuppets, 0)
  21.     goTyping(mdispose)
  22.   end if
  23.   set the keyDownScript to "QuitKeyDown"
  24. end
  25.  
  26. on ShowTheName
  27.   global theNameSprite
  28.   set the visible of sprite theNameSprite to 1
  29. end
  30.  
  31. on HideTheName
  32.   global theNameSprite
  33.   set the visible of sprite theNameSprite to 0
  34. end
  35.  
  36. on Page0StopAllSound
  37.   global QTspriteNum
  38.   if the visible of sprite QTspriteNum = 1 then
  39.     set the movieRate of sprite QTspriteNum to 0
  40.     set the movieTime of sprite QTspriteNum to 0
  41.     set the visible of sprite QTspriteNum to 0
  42.   end if
  43.   puppetSound(0)
  44.   updateStage()
  45. end
  46.  
  47. factory fTyping
  48. method mnew
  49.   instance exitFrame, gCategoryNum, gFromIndexFlag, ichFirstLetter, iMaxLetters, iNameString, iLetterNumber, iLowerLetters, iLetters, iLetterHit, iNextH
  50.   global gPlaceHolder
  51.   set iMaxLetters to 9
  52.   set ichFirstLetter to 4
  53.   set iLetterNumber to 1
  54.   set iNameString to "         "
  55.   set iLowerLetters to "abcdefghijklmnopqrstuvwxyz"
  56.   set iLetters to "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-'. "
  57.   set iNextH to the left of sprite ichFirstLetter
  58.   me(mSetPuppets, 1)
  59.  
  60. method mSetPuppets trueOrFalse
  61.   repeat with i = ichFirstLetter to ichFirstLetter + iMaxLetters - 1
  62.     puppetSprite(i, trueOrFalse)
  63.     set the stretch of sprite i to 0
  64.   end repeat
  65.  
  66. method mHitKey
  67.   global gLastKey
  68.   if (the key = RETURN) or ((the key = ENTER) and (iLetterNumber > 1)) then
  69.     placeName()
  70.     exit
  71.   end if
  72.   if the commandDown or the controlDown or the optionDown then
  73.     set the exitLock to 1
  74.     if the machineType = 256 then
  75.       if the controlDown and (the key = "Q") then
  76.         set gQuitReturn to the movieName
  77.         go(1, "Quit.dir")
  78.       end if
  79.     else
  80.       if the commandDown and ((the key = "Q") or (the key = ".")) then
  81.         set gQuitReturn to the movieName
  82.         go(1, "Quit.dir")
  83.       end if
  84.     end if
  85.     exit
  86.   end if
  87.   set iLetterHit to the key
  88.   if iLetterHit = BACKSPACE then
  89.     set gLastKey to " "
  90.     if iLetterNumber = 1 then
  91.       beep()
  92.     else
  93.       set iLetterNumber to iLetterNumber - 1
  94.       set gLastKey to char iLetterNumber - 1 of iNameString
  95.       put " " into char iLetterNumber of iNameString
  96.       me(mDrawAll)
  97.     end if
  98.   else
  99.     if iLetterNumber > iMaxLetters then
  100.       beep()
  101.       exit
  102.     end if
  103.     set theLetterOffset to 0
  104.     set theLetterOffset to offset(iLetterHit, iLowerLetters)
  105.     if theLetterOffset <> 0 then
  106.       set iLetterHit to chars(iLetters, theLetterOffset, theLetterOffset)
  107.     else
  108.       set theLetterOffset to offset(iLetterHit, iLetters)
  109.     end if
  110.     if theLetterOffset = 0 then
  111.       beep()
  112.       exit
  113.     end if
  114.     set gLastKey to iLetterHit
  115.     put iLetterHit into char iLetterNumber of iNameString
  116.     me(mDraw)
  117.     set iLetterNumber to iLetterNumber + 1
  118.     dontPassEvent()
  119.   end if
  120.  
  121. method mDraw
  122.   global gPlaceHolder
  123.   set theChannel to ichFirstLetter + iLetterNumber - 1
  124.   set theLetter to char iLetterNumber of iNameString
  125.   set theLetterOffset to offset(theLetter, iLetters)
  126.   set theNewCast to the number of cast "FirstLetter" + theLetterOffset - 1
  127.   set the castNum of sprite theChannel to theNewCast
  128.   set the locH of sprite theChannel to iNextH
  129.   updateStage()
  130.   set iNextH to iNextH + (the right of sprite theChannel - the left of sprite theChannel)
  131.   set gPlaceHolder to iNextH
  132.  
  133. method mDrawAll
  134.   global gFullName, gPlaceHolder
  135.   set iNextH to the left of sprite ichFirstLetter
  136.   repeat with i = 1 to iMaxLetters
  137.     set theChannel to ichFirstLetter + i - 1
  138.     set theLetter to char i of iNameString
  139.     set theLetterOffset to offset(theLetter, iLetters)
  140.     set theNewCast to the number of cast "FirstLetter" + theLetterOffset - 1
  141.     set the castNum of sprite theChannel to theNewCast
  142.     set the locH of sprite theChannel to iNextH
  143.     if i < iLetterNumber then
  144.       set iNextH to iNextH + (the right of sprite theChannel - the left of sprite theChannel)
  145.     end if
  146.   end repeat
  147.   updateStage()
  148.   set gPlaceHolder to iNextH
  149.   set gFullName to iNameString
  150.  
  151. method mPronounceLetter
  152.   set castNameToPlay to iLetterHit
  153.   if castNameToPlay = "'" then
  154.     set castNameToPlay to "Apostrophe"
  155.   else
  156.     if castNameToPlay = " " then
  157.       set castNameToPlay to "Space"
  158.     else
  159.       if castNameToPlay = "-" then
  160.         set castNameToPlay to "Hyphen"
  161.       else
  162.         if castNameToPlay = "." then
  163.           set castNameToPlay to "Period"
  164.         end if
  165.       end if
  166.     end if
  167.   end if
  168.   pPlayMySound(castNameToPlay)
  169.